
/**
 *	\file Definition of the nmn::create_string function.
 *	\author Sean Tromans
 */

#ifndef	NMN_CREATE_STRING_HPP
#define	NMN_CREATE_STRING_HPP

#include <boost/format.hpp>
#include <boost/preprocessor.hpp>

#ifndef	NMN_CREATE_STRING_TOTAL_PARAMS
#define	NMN_CREATE_STRING_TOTAL_PARAMS	10
#endif	//NMN_CREATE_STRING_TOTAL_PARAMS

#define	NMN_DEFINE_CREATE_STRING_PARAMS(z,n,_)	% BOOST_PP_CAT( p, n )

#define	NMN_DEFINE_CREATE_STRING(z, n, _)																											\
	template < BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(n), class T) >																				\
	inline std::string create_string( std::string const & format, BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_INC(n), T, const & p) )					\
	{																																				\
		return boost::str( boost::format( format ) BOOST_PP_CAT( BOOST_PP_REPEAT_, z )( BOOST_PP_INC(n), NMN_DEFINE_CREATE_STRING_PARAMS, _) );		\
	}

namespace nmn
{

	/**
	 *	Creates an output string from a format and values.
	 *	\sa <a href="http://www.boost.org/doc/libs/1_41_0/libs/format/index.html">Boost Format library</a>
	 *	@param format The format the string should take.
	 *	@return The generated string.
	 *	\author Sean Tromans
	 */
	inline std::string create_string( std::string const & format )
	{
		return format;
	}

	BOOST_PP_REPEAT( BOOST_PP_INC(NMN_CREATE_STRING_TOTAL_PARAMS), NMN_DEFINE_CREATE_STRING, 0 );

};

#undef	NMN_DEFINE_CREATE_STRING
#undef	NMN_DEFINE_CREATE_STRING_PARAMS

#endif	//NMN_CREATE_STRING_HPP
